package com.management.service.wes.impl;
import com.management.dao.wes.SalTbShpcdMapper;
import com.management.service.wes.IGzpService;
import com.management.common.ServerResponse;
import com.management.dao.wes.PurTbRcvdMapper;
import com.management.dao.wes.PurTbRcvMapper;
import com.management.dao.report.CaseIdMapper;
import com.management.util.DataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

@Service
@Transactional
public class GzpServiceImpl implements IGzpService {
    @Autowired
    PurTbRcvdMapper purTbRcvdMapper;
    @Autowired
    PurTbRcvMapper purTbRcvMapper;
    @Autowired
    CaseIdMapper caseIdMapper;
    @Autowired
    SalTbShpcdMapper salTbShpcdMapper;
    @Override
    public ServerResponse getGzpData(String date_begin, String date_end) {
        DataSourceContextHolder.setDbType(DataSourceContextHolder.SESSION_FACTORY_WES);
        Map<String, Object> result = new HashMap<>();
        //一般图书
        Map<String, Integer> map = new HashMap<>();
        int ytF = purTbRcvdMapper.getGzpData(date_begin,date_end);
        map.put("ytF",ytF);
        int ytF1 = purTbRcvdMapper.getGzpData1(date_begin,date_end);
        map.put("ytF1",ytF1);
        int ytU = purTbRcvMapper.getGzpData2(date_begin,date_end);
        map.put("ytU",ytU);
        int ytU1 = purTbRcvdMapper.getGzpData3(date_begin,date_end);
        map.put("ytU1",ytU1);
        result.put("yt", map);
        //农家书屋
        Map<String, Integer> map1 = new HashMap<>();
        int njF = purTbRcvdMapper.getGzpData4(date_begin,date_end);
        map1.put("njF",njF);
        int njF1 = purTbRcvdMapper.getGzpData5(date_begin,date_end);
        map1.put("njF1",njF1);
        int njU = purTbRcvMapper.getGzpData6(date_begin,date_end);
        map1.put("njU",njU);
        int njU1 = purTbRcvdMapper.getGzpData7(date_begin,date_end);
        map1.put("njU1",njU1);
        result.put("nj", map1);
        //退货
        Map<String, Integer> map2 = new HashMap<>();
        int thF = purTbRcvdMapper.getGzpData8(date_begin,date_end);
        map2.put("thF",thF);
        int thF1 = purTbRcvdMapper.getGzpData9(date_begin,date_end);
        map2.put("thF1",thF1);
        int thU = purTbRcvMapper.getGzpData10(date_begin,date_end);
        map2.put("thU",thU);
        int thU1 = purTbRcvdMapper.getGzpData11(date_begin,date_end);
        map2.put("thU1",thU1);
        result.put("th", map2);
        //一般图书够包
        DataSourceContextHolder.setDbType(DataSourceContextHolder.SESSION_FACTORY_PRD1);
        Map<String, Integer> map3 = new HashMap<>();
        int ytg = caseIdMapper.getGzpData12(date_begin,date_end);
        map3.put("ytg",ytg);
        int ytg1 = caseIdMapper.getGzpData13(date_begin,date_end);
        map3.put("ytg1",ytg1);
        result.put("ytg", map3);
        //农家书屋够包
        Map<String, Integer> map4 = new HashMap<>();
        int njg = caseIdMapper.getGzpData14(date_begin,date_end);
        map4.put("njg",njg);
        int njg1 = caseIdMapper.getGzpData15(date_begin,date_end);
        map4.put("njg1",njg1);
        result.put("njg", map4);
        //今日封箱
        DataSourceContextHolder.setDbType(DataSourceContextHolder.SESSION_FACTORY_WES);
        Map<String, Integer> map5 = new HashMap();
        int ytj = this.salTbShpcdMapper.getGzpData16(date_begin, date_end);
        map5.put("ytj", Integer.valueOf(ytj));
        int ytj1 = this.salTbShpcdMapper.getGzpData17(date_begin, date_end);
        map5.put("ytj1", Integer.valueOf(ytj1));
        int njj = this.salTbShpcdMapper.getGzpData18(date_begin, date_end);
        map5.put("njj", Integer.valueOf(njj));
        int njj1 = this.salTbShpcdMapper.getGzpData19(date_begin, date_end);
        map5.put("njj1", Integer.valueOf(njj1));
        int thj = this.salTbShpcdMapper.getGzpData20(date_begin, date_end);
        map5.put("thj", Integer.valueOf(thj));
        int thj1 = this.salTbShpcdMapper.getGzpData21(date_begin, date_end);
        map5.put("thj1", Integer.valueOf(thj1));
        result.put("jr", map5);
        return ServerResponse.createBySuccess(result);
    }
}
